home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Workbench Design
/
WB Collection.iso
/
workbench werkzeuge
/
backdroppic. tools
/
rndbackdrop
/
rndbackdrop
< prev
next >
Wrap
Text File
|
1996-04-07
|
3KB
|
115 lines
/* RndBackdrop 1.0 - Copy a random backdrop into a certain file
** optionally reload WBPattern
**
** By Reinhard Katzmann
**/
version='$VER: rndbackdrop 1.0 (8.8.94)
'
SIGNAL ON BREAK_D
SIGNAL ON BREAK_C
OPTIONS RESULTS
if ~show('L', 'rexxdossupport.library') then /* Just for ReadArgs() */
call addlib('rexxdossupport.library',0,-30)
if ~show('L', 'rexxarplib.library') then /* For Getenv() */
call addlib('rexxarplib.library',0,-30)
/* Parse arguments */
/* Usage: rndbackdrop TO,Infile/K,TMPFile/K,TMPPrefs/K,RELOAD/S,MSG/S */
parse arg args
template = 'TO,Infile/K,TMPFile/K,TMPPrefs/K,RELOAD/S,MSG/S'
WBBDC=Getenv("WBBACKDROPCMD") /* Use this for your personal WBBackdrop Command */
if WBBDC=='' then WBBDC='WBPattern use' /* Do not load WBPattern GUI */
TO='dh0:t/bdpic'
Infile='dh0:t/backdrops'
TMPFile='dh0:t/oldpic'
TMPPrefs='dh0:t/tmpprefs' /* Must include the name of TMPFile !! */
RELOAD=0
MSG=0 /* Switch MSG if you want to know what picture has been selected */
if (args=='?') then do
writech(stdout,template': ')
parse pull moreargs
if (moreargs=='?') then do
say "rndfile"
say "Written by Reinhard Katzmann"
say version
say ""
say "Usage: rndbackdrop "template
say ""
say "Examples:"
say " RX rndbackdrop"
say " load the default backdrop list, copies it to default rndbackdrop"
say " defaults are: dh0:t/backdrops (file list), dh0:t/bdpic (picture)"
say ""
say " RX rndbackdrop sys:prefs/presets/mypic Infile=sys:prefs/presets/piclist"
say " Select a random pic from piclist and copy is to mypic"
say ""
say " RX rndbackdrop TMPFile=dh0:t/mytmp TMPPrefs=dh0:t/myprefs RELOAD"
say " Select random pic as in first example, but notifies WBPattern"
say " to use the new picture, tmp file will be deleted afterwards"
exit
end
else args=moreargs
end
ReadArgs(args,template)
/* Main Program */
if (~exists(Infile)) then do
say "Infile Pic List "Infile" does not exists."
exit
end
/* Open and read backdrop picture list */
if (~open('fp',Infile,'R')) then do
say "Could not open file "Infile" for reading."
exit
end
numfiles=0
do until EOF('fp')
numfiles=numfiles+1
thefile.numfiles=readln('fp')
end
if reload==1 then do /* Rename the old pic, used later by old prefs */
if (~exists(TO)) then do
say "Old picture "TO" is missing, no reload possible"
exit
end
ADDRESS COMMAND 'rename "'TO'" "'TMPFile'"'
end
/* Now we have read the pic list, we may handle it */
if numfiles>0 then do
rnum = random(1,numfiles,random(1,100,(TIME(SECONDS))))
name=thefile.rnum
ADDRESS COMMAND 'copy "'name'" "'TO'"'
if MSG==1 then say "Backdrop chosen was "name"."
end
else do
say "File "Infile" is empty."
exit
end
if reload==1 then do
ADDRESS COMMAND WBBDC' "'TMPPrefs'"' /* Load the tmp prefs (without picname) */
ADDRESS COMMAND WBBDC' envarc:sys/WBPattern.prefs' /* Öpad the new pic */
ADDRESS COMMAND 'WAIT 1' /* Necessary, because else sometimes TMPfile can't be deleted */
ADDRESS COMMAND 'Delete "'TMPFile'"' /* Delete tmp file */
end
BREAK_D:
exit
BREAK_C:
exit